﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Manage_GoodsTrendUpdate : System.Web.UI.Page
{
    public string strName1, strContent1;
    public string TrendID;
    protected void Page_Load(object sender, EventArgs e)
    {
        TrendID = Request.QueryString["TrendID"].ToString();
        string strName, strContent;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (!IsPostBack)
            {
                string strSql;
                if (Request.QueryString["TrendID"] != null)
                    TrendID = SysFun.IsSQL(Request.QueryString["TrendID"].ToString());
                else
                    return;
                strSql = "select * from GoodsTrend where TrendID=" + TrendID;
                Db DbInfo = new Db();
                System.Data.IDataReader dr;
                dr = DbInfo.DataReader(strSql);
                if (dr.Read())
                {
                    txtAccountId.Text = dr["AccountId"].ToString();
                    txtAccountId.Visible = false;
                    txtAddDate.Text = Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                    txtInfoId.Text = dr["TrendID"].ToString();
                    txtInfoId.Visible = false;
                    strName1 = dr["Title"].ToString();
                    strContent1 = dr["Content"].ToString();

                }
                dr.Close();
                dr.Dispose();
                DbInfo.Close();
            }
            strName = SysFun.ToTrim(Request.Form["txtName"]);
            strContent = SysFun.ToTrim(Request.Form["txtContentHtml"]);
            if (strName != "" && strContent != "")
            {
                Db db = new Db();
                Grove.ORM.ObjectOperator oo = db.GetObjectOperator();
                HZ.MBSM.Model.GoodsTrend GoodsTrend = new HZ.MBSM.Model.GoodsTrend();
                GoodsTrend.Title = strName;
                GoodsTrend.Content = strContent.Replace("\r\n", "");
                GoodsTrend.AccountId = Convert.ToInt64(txtAccountId.Text);
                GoodsTrend.AddDate = Convert.ToDateTime(txtAddDate.Text);
                GoodsTrend.DownLoad = "";
                GoodsTrend.TrendID = Convert.ToInt32(TrendID);
                oo.Update(GoodsTrend);
                oo.Dispose();
                db.Close();
                Response.Write("<script>alert('保存成功！！！');</script>");
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "GoodsTrend", GoodsTrend.Title + "|" + GoodsTrend.Content + "|" + GoodsTrend.AddDate + "|" + GoodsTrend.AccountId, "../Magage/GoodsTrendUpdate.aspx");


                Response.Write("<script>window.opener.location.reload();window.close();</script>");
            }
        }
    }
}
